Skip to content

[nrf fromlist] GRTC optimizations #2740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nordic-krch
Copy link
Contributor

Changes in GRTC system clock driver that reduce time spend in GRTC calls by approx. 50%.

PR created to run NCS CI on that change.

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Apr 10, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@nordic-krch nordic-krch force-pushed the ncs/grtc_optimization branch 2 times, most recently from 0d72e4d to 9c533ef Compare April 24, 2025 11:18
@nordic-krch nordic-krch force-pushed the ncs/grtc_optimization branch 6 times, most recently from 813d1ec to c01b11c Compare May 12, 2025 11:57
@nordic-krch nordic-krch force-pushed the ncs/grtc_optimization branch 3 times, most recently from 0a523b9 to a9d803b Compare May 14, 2025 08:10
@nordic-krch nordic-krch force-pushed the ncs/grtc_optimization branch 6 times, most recently from ec5b435 to 3ca0b86 Compare May 26, 2025 06:13
@nordic-krch nordic-krch force-pushed the ncs/grtc_optimization branch from 3ca0b86 to d11f72e Compare June 11, 2025 14:13
@nordic-krch nordic-krch marked this pull request as ready for review June 11, 2025 14:13
@lemrey
Copy link
Contributor

lemrey commented Jun 11, 2025

👏👏👏

@nordic-krch nordic-krch force-pushed the ncs/grtc_optimization branch 2 times, most recently from bca3794 to 1172c56 Compare June 23, 2025 06:21
@nordic-krch nordic-krch force-pushed the ncs/grtc_optimization branch 3 times, most recently from 3f659e2 to 4552b8f Compare June 25, 2025 07:58
@nordic-krch nordic-krch force-pushed the ncs/grtc_optimization branch 2 times, most recently from a104b59 to 094ca6f Compare July 2, 2025 05:11
Copy link

sonarqubecloud bot commented Jul 2, 2025

@nordic-krch nordic-krch force-pushed the ncs/grtc_optimization branch from 094ca6f to 331765f Compare July 8, 2025 09:51
@@ -428,22 +432,15 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
}
#endif /* CONFIG_POWEROFF */


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could be redundant

@nordic-krch nordic-krch force-pushed the ncs/grtc_optimization branch 3 times, most recently from a620088 to 31374c8 Compare July 11, 2025 06:22
nordic-krch and others added 4 commits July 15, 2025 08:45
… initialization"

This reverts commit de4fad1.

Signed-off-by: Krzysztof Chruściński <[email protected]>
…ization

The GRTC counter is not cleared at startup, therefore the
`last_count` variable needs to be initialized accordingly.
This change:
- Prevents overflow of the `sys_clock_announce()` int32_t parameter
- Ensures the correct uptime value, which should be reset during
  initialization

Signed-off-by: Adam Kondraciuk <[email protected]>
(cherry picked from commit e77f942cff5516140f7db48bb42eda49522c1c7a)
…ister access

Speed up execution of the interrupt handler and sys_clock_set_timeout().
Sys_clock_set_timeout() can be called in two scenarios: from previous
timeout expiration handler or freely. If the former case fast path
can be used since CC value in the GRTC register just expired and it
can be used as a reference for CCADD setting. This is only a single
register write so it's much faster. In the latter a longer procedure
is applied which also happens in two variants. If value which is
set in CC is further in the future (e.g. K_FOREVER was set before) then
CC can be safely overwritten with a new value without a risk of
triggering unexpected COMPARE event. If value in CC is earlier than
the new CC value (if earlier timeout was aborted) then there is a
risk of COMPARE event happening while it is being overwritten.
That case requires long and safer procedure of setting CC.

Update hal_nordic with changes in the nrfx_grtc driver which are
needed for nrf_grtc_timer changes.

Upstream PR #: 87944

Signed-off-by: Krzysztof Chruściński <[email protected]>
Add stress test that randomly starts and aborts multiple timers
from various contexts. Test checks if timers do not expire prematurely.

Upstream PR #: 87944

Signed-off-by: Krzysztof Chruściński <[email protected]>
@nordic-krch nordic-krch force-pushed the ncs/grtc_optimization branch from 20870c6 to b3bbeb5 Compare July 15, 2025 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants